package com.itlong.cloud.operate.resource;

import com.itlong.cloud.POJO.DTO.operate.*;
import com.itlong.cloud.POJO.VO.operate.OperatePaperGetVO;
import com.itlong.cloud.POJO.VO.operate.OperatePaperImgGetVO;
import com.itlong.cloud.noncore.operate.IOperatePaperServiceClient;
import com.itlong.cloud.operate.service.IOperatePaperService;
import com.itlong.cloud.utils.page.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <desc>
 *      运营-系统管理-说明书管理暴露接口实现类
 * </desc>
 *
 * @createDate 2018/06/27
 */
@RestController
public class OperatePaperServiceResource implements IOperatePaperServiceClient {

    @Autowired
    private IOperatePaperService iOperatePaperService;

    /**
     * <desc>
     *      分页获取说明书信息
     * </desc>
     *
     * @param operatePaperGetPageDTO 说明书管理分页查询说明书数据传输对象
     * @return 分页查询结果对象
     * @author wangzhi
     * @createDate 2018/06/27
     */
    @Override
    @PostMapping(path = "operate/paper/getPapersByPage")
    public Page<OperatePaperGetVO> getPapersByPage(@RequestBody OperatePaperGetPageDTO operatePaperGetPageDTO) throws Exception {
        return iOperatePaperService.getPapersByPage(operatePaperGetPageDTO);
    }

    /**
     * <desc>
     *      精确查询单个说明书信息
     * </desc>
     *
     * @param operatePaperGetOneDTO 说明书管理单个精确查询说明书数据传输对象
     * @return 单个结果查询对象
     * @author wangzhi
     * @createDate 2018/06/28
     */
    @Override
    @PostMapping(path = "operate/paper/getOnePaper")
    public OperatePaperGetVO getOnePaper(@RequestBody OperatePaperGetOneDTO operatePaperGetOneDTO) throws Exception {
        return iOperatePaperService.getOnePaper(operatePaperGetOneDTO);
    }

    /**
     * <desc>
     *      保存说明书信息
     * </desc>
     *
     * @param operatePaperSaveDTO 说明书管理保存说明书数据传输对象
     * @return 受影响的行数
     * @throws Exception 不可预见性异常
     * @author wangzhi
     * @createDate 2018/06/28
     */
    @Override
    @PostMapping(path = "operate/paper/savePaper")
    public Integer savePaper(@RequestBody OperatePaperSaveDTO operatePaperSaveDTO) throws Exception {
        return iOperatePaperService.savePaper(operatePaperSaveDTO);
    }

    /**
     * <desc>
     *      修改说明书信息
     * </desc>
     *
     * @param operatePaperUpdateDTO 说明书管理修改说明书数据传输对象
     * @return 受影响的行数
     * @author wangzhi
     * @createDate 2018/06/29
     */
    @Override
    @PostMapping(path = "operate/paper/updatePaper")
    public Integer updatePaper(@RequestBody OperatePaperUpdateDTO operatePaperUpdateDTO) throws Exception {
        return iOperatePaperService.updatePaper(operatePaperUpdateDTO);
    }

    /**
     * <desc>
     *      删除说明书信息
     * </desc>
     *
     * @param paperId 说明书id
     * @return 受影响的行数
     * @author wangzhi
     * @createDate 2018/06/29
     */
    @Override
    @PostMapping(path = "operate/paper/deletePaper")
    public Integer deletePaper(@RequestParam("paperId")String paperId) throws Exception {
        return iOperatePaperService.deletePaper(paperId);
    }

    /**
     * <desc>
     *      查看说明书详情
     * </desc>
     *
     * @param operatePaperImgGetDTO 查询参数
     * @return 获取说明书详情信息VO
     * @author wangzhi
     * @createDate 2018/07/02
     */
    @Override
    @PostMapping(path = "operate/paper/getPaperImg")
    public OperatePaperImgGetVO getPaperImg(@RequestBody OperatePaperImgGetDTO operatePaperImgGetDTO) throws Exception{
        return iOperatePaperService.getPaperImg(operatePaperImgGetDTO);
    }

    /**
     * <desc>
     *      添加说明书详情
     * </desc>
     *
     * @param operatePaperImgSaveOrUpdateDTO 添加数据参数
     * @return 受影响的行数
     * @author wangzhi
     * @createDate 2018/07/02
     */
    @Override
    @PostMapping(path = "operate/paper/savePaperImg")
    public Integer savePaperImg(@RequestBody OperatePaperImgSaveOrUpdateDTO operatePaperImgSaveOrUpdateDTO) throws Exception {
        return iOperatePaperService.savePaperImg(operatePaperImgSaveOrUpdateDTO);
    }

    /**
     * <desc>
     *      编辑(替换)说明书详情图片
     * </desc>
     *
     * @param operatePaperImgSaveOrUpdateDTO 修改数据参数
     * @return 受影响的行数
     * @author wangzhi
     * @createDate 2018/07/02
     */
    @Override
    @PostMapping(path = "operate/paper/updatePaperImg")
    public Integer updatePaperImg(@RequestBody OperatePaperImgSaveOrUpdateDTO operatePaperImgSaveOrUpdateDTO) throws Exception {
        return iOperatePaperService.updatePaperImg(operatePaperImgSaveOrUpdateDTO);
    }

    /**
     * <desc>
     *      删除说明书详情
     * </desc>
     *
     * @param operatePaperImgDeleteDTO 删除说明书详情数据传输对象
     * @return 受影响的行数
     * @throws Exception
     * @author wangzhi
     * @createDate 2018/07/02
     */
    @Override
    @PostMapping(path = "operate/paper/deletePaperImg")
    public Integer deletePaperImg(@RequestBody OperatePaperImgDeleteDTO operatePaperImgDeleteDTO) throws Exception {
        return iOperatePaperService.deletePaperImg(operatePaperImgDeleteDTO);
    }
}
